﻿using System.Windows;

namespace Koala.Pro.Helpers
{
    public static class MessageDxUtil
    {
        private static string Caption_Tips;

        private static string Caption_Warning;

        private static string Caption_Error;

        static MessageDxUtil()
        {
            Caption_Tips = "提示信息";
            Caption_Warning = "警告信息";
            Caption_Error = "错误信息";
            Caption_Tips = JsonLanguage.Default.GetString(Caption_Tips);
            Caption_Warning = JsonLanguage.Default.GetString(Caption_Warning);
            Caption_Error = JsonLanguage.Default.GetString(Caption_Error);
        }

        public static MessageBoxResult ShowTips(string message)
        {
            return ShowTips(message, null);
        }

        public static MessageBoxResult ShowTips(string message, params object[] args)
        {
            message = JsonLanguage.Default.GetString(message);
            if (args != null)
            {
                message = string.Format(message, args);
            }
            return MessageBox.Show(message, Caption_Tips, MessageBoxButton.OK, MessageBoxImage.Asterisk);
        }

        public static MessageBoxResult ShowWarning(string message)
        {
            return ShowWarning(message, null);
        }

        public static MessageBoxResult ShowWarning(string message, params object[] args)
        {
            message = JsonLanguage.Default.GetString(message);
            if (args != null)
            {
                message = string.Format(message, args);
            }
            return MessageBox.Show(message, Caption_Warning, MessageBoxButton.OK, MessageBoxImage.Exclamation);
        }

        public static MessageBoxResult ShowError(string message)
        {
            return ShowError(message, null);
        }

        public static MessageBoxResult ShowError(string message, params object[] args)
        {
            message = JsonLanguage.Default.GetString(message);
            if (args != null)
            {
                message = string.Format(message, args);
            }
            return MessageBox.Show(message, Caption_Error, MessageBoxButton.OK, MessageBoxImage.Hand);
        }

        public static MessageBoxResult ShowYesNoAndError(string message)
        {
            return ShowYesNoAndError(message, null);
        }

        public static MessageBoxResult ShowYesNoAndError(string message, params object[] args)
        {
            message = JsonLanguage.Default.GetString(message);
            if (args != null)
            {
                message = string.Format(message, args);
            }
            return MessageBox.Show(message, Caption_Error, MessageBoxButton.YesNo, MessageBoxImage.Hand);
        }

        public static MessageBoxResult ShowYesNoAndTips(string message)
        {
            return ShowYesNoAndTips(message, null);
        }

        public static MessageBoxResult ShowYesNoAndTips(string message, params object[] args)
        {
            message = JsonLanguage.Default.GetString(message);
            if (args != null)
            {
                message = string.Format(message, args);
            }
            return MessageBox.Show(message, Caption_Tips, MessageBoxButton.YesNo, MessageBoxImage.Asterisk);
        }

        public static MessageBoxResult ShowYesNoAndWarning(string message)
        {
            return ShowYesNoAndWarning(message, null);
        }

        public static MessageBoxResult ShowYesNoAndWarning(string message, params object[] args)
        {
            message = JsonLanguage.Default.GetString(message);
            if (args != null)
            {
                message = string.Format(message, args);
            }
            return MessageBox.Show(message, Caption_Warning, MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
        }

        public static MessageBoxResult ShowYesNoCancelAndTips(string message)
        {
            return ShowYesNoCancelAndTips(message, null);
        }

        public static MessageBoxResult ShowYesNoCancelAndTips(string message, params object[] args)
        {
            message = JsonLanguage.Default.GetString(message);
            if (args != null)
            {
                message = string.Format(message, args);
            }
            return MessageBox.Show(message, Caption_Tips, MessageBoxButton.YesNoCancel, MessageBoxImage.Asterisk);
        }

        public static bool ConfirmYesNo(string message)
        {
            message = JsonLanguage.Default.GetString(message);
            return MessageBox.Show(message, Caption_Tips, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;
        }

        public static MessageBoxResult ConfirmYesNoCancel(string message)
        {
            return MessageBox.Show(message, Caption_Tips, MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
        }
    }

}
